package com.threeox.commonlibrary.ui.view.pullrefresh;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ScrollView;

import com.threeox.commonlibrary.ui.view.inter.pullrefresh.IPullable;

/**
 *
 * @ClassName: PullToRefreshScrollView
 *
 * @Description: TODO(可以上拉和下拉的ScrollView)
 *
 * @author 赵屈犇
 *
 * @date 创建时间: 2017/6/29 16:41
 *
 * @version 1.0
 *
 */
@SuppressWarnings("ResourceAsColor")
public class PullToRefreshScrollView extends ScrollView implements IPullable {

	public PullToRefreshScrollView(Context context) {
		this(context, null);
	}

	public PullToRefreshScrollView(Context context, AttributeSet attrs) {
		this(context, attrs, 0);
	}

	public PullToRefreshScrollView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}

	@Override
	public boolean isPullDown() {
		if (getScrollY() == 0)
			return true;
		else
			return false;
	}

	@Override
	public boolean isPullUp() {
		if (getScrollY() >= (getChildAt(0).getHeight() - getMeasuredHeight()))
			return true;
		else
			return false;
	}

}
